home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 3 / Info_Mac_1994-01.iso / Development / Source / Arashi 1.1 Source / For your think c folder / Sound Kit ƒ / DataFiles.c next >
Encoding:
C/C++ Source or Header  |  1992-09-09  |  1.9 KB  |  89 lines  |  [TEXT/KAHL]

  1. /*/
  2.      Project Arashi: DataFiles.c
  3.      Major release: Version 1.1, 7/22/92
  4.  
  5.      Last modification: Wednesday, September 9, 1992, 21:39
  6.      Created: Saturday, October 6, 1990, 16:32
  7.  
  8.      Copyright © 1990-1992, Juri Munkki
  9. /*/
  10.  
  11. /*
  12. >>    This subroutines reads all data forks of a certain type from
  13. >>    the folder where it is run.
  14. >>
  15. >>    ReadDataFiles is only used by the compressing
  16. >>    part of the sound kit. You have to include this
  17. >>    file even if you are only decompressing the
  18. >>    sounds. Of course, the linker will remove this
  19. >>    routine when (and if) it notices that it's not used.
  20. */
  21.  
  22. #include "Shuddup.h"
  23.  
  24.  
  25. Handle    ReadDataFiles(ftype)
  26. long    ftype;
  27. {
  28.     register    Handle            fdata;
  29.     register    Handle            sinfo;
  30.     register    long            datasize;
  31.                 long            len;
  32.     register    int                numfiles,i,numread;
  33.                 int                ref;
  34.                 volumeParam        volupram;
  35.                 fileParam        filepram;
  36.                 char            fname[256];
  37.     
  38.     sinfo=GetResource(SKRESTYPE,SKSTABLE);
  39.     fdata=NewHandle(0);
  40.     datasize=0;
  41.  
  42.     volupram.ioCompletion=0;
  43.     volupram.ioNamePtr=0;
  44.     volupram.ioVRefNum=0;
  45.     volupram.ioVolIndex=0;
  46.     
  47.     PBGetVInfo(&volupram,0);
  48.  
  49.     numfiles=volupram.ioVNmFls;
  50.  
  51.     filepram.ioCompletion=0;
  52.     filepram.ioVRefNum=0;
  53.     filepram.ioFVersNum=0;
  54.     filepram.ioNamePtr=(void *)fname;
  55.     
  56.     numread=0;
  57.     for(i=1;i<=numfiles;i++)
  58.     {    filepram.ioFDirIndex=i;
  59.         if(PBGetFInfo(&filepram,0)==0)
  60.         {    if(filepram.ioFlFndrInfo.fdType==ftype)
  61.             {    if(FSOpen(fname,0,&ref)==0)
  62.                 {    if(GetEOF(ref,&len)==0)
  63.                     {    SetHandleSize(fdata,datasize+len);
  64.                         if(!MemErr)
  65.                         {    HLock(fdata);
  66.                             FSRead(ref,&len,datasize+*fdata);
  67.                             datasize+=len;
  68.                             HUnlock(fdata);
  69.                             
  70.                             numread++;
  71.                             SetHandleSize(sinfo,numread*sizeof(long));
  72.                             if(!MemErr)
  73.                             {    ((long *)(*sinfo))[numread-1]=len;
  74.                             }
  75.                         }
  76.                     }
  77.                     FSClose(ref);
  78.                 }
  79.             }
  80.         }
  81.     }
  82.     if(datasize==0)
  83.     {    datasize=10;
  84.     }
  85.     SetHandleSize(fdata,datasize);
  86.     ChangedResource(sinfo);
  87.     WriteResource(sinfo);
  88.     return fdata;
  89. }